package util;

import entity.Result;
import entity.StatusCode;
import enums.ResultEnum;

public class ResultUtil {

    public static Result successMsg(String message) {
        return new Result(true, StatusCode.OK, message);
    }

    public static Result success() {
        return success(null);
    }

    public static Result success(Object data) {
        return new Result(true, StatusCode.OK, "success", data);
    }

    public static Result error() {
        return new Result(false, StatusCode.ERROR, "error");
    }

    public static Result errorMsg(String message) {
        return new Result(false, StatusCode.ERROR, message);
    }

    public static Result valueOf(ResultEnum resultEnum) {
        return new Result(resultEnum.isFlag(), resultEnum.getCode(), resultEnum.getMessage());
    }


}
